package instructions;
import Computer.ProgramCounter;
import memory.Address;
import memory.Memory;
import memory.Word;
import memory.WordFinder;


public abstract class Arithmetic implements Instruction{
	protected WordFinder address1;
	protected Address address2;
	protected WordFinder word;
	
	public Arithmetic(WordFinder address1, WordFinder word, Address address2){
		this.address1 = address1;
		this.address2 = address2;
		this.word = word;
	}
	
	
	
	public void execute(Memory memory, ProgramCounter counter) {	
		Word returnWord = operate(address1.getWord(memory), word.getWord(memory));
		memory.setWord(address2, returnWord);
		counter.increase();
	}
	
	protected abstract Word operate(Word memory, Word newWord);
		
	
}
